package com.tsd.jxc.pub.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.annotation.Resource;

import com.tsd.core.utils.HlpUtils;
import com.tsd.core.vo.PageBean;
import com.tsd.jxc.pub.service.JxcDetailSnService;
import com.tsd.jxc.pub.entity.JxcDetailSn;
import com.tsd.jxc.pub.entity.JxcDetailSnExt;
import com.tsd.system.entity.SysUser;
import com.tsd.jxc.pub.dao.JxcDetailSnMapper;
import org.springframework.stereotype.Service;
import com.tsd.service.BaseServiceImpl;

/**
 * 描述：JxcDetailSn 服务实现层
 *
 * @author david
 * @date 2024/05/07 17:02:29
 */
@Service
public class JxcDetailSnServiceImpl extends BaseServiceImpl implements JxcDetailSnService {

    @Resource
    private JxcDetailSnMapper jxcDetailSnMapper;

    @Override
    public JxcDetailSn getJxcDetailSnById(Long id)throws Exception {
        return jxcDetailSnMapper.selectByPrimaryKey(id);
    }

    @Override
    public JxcDetailSnExt queryBySid(String sid) throws Exception {
    return jxcDetailSnMapper.selectBySid(sid);
    }

    @Override
    public void deleteJxcDetailSns(List<String> list, SysUser opUser)throws Exception {
        for (String sid:list){
            JxcDetailSn old = jxcDetailSnMapper.selectBySid(sid);
            super.checkEmpty(old,"该记录不存在");
            super.autoInjectBaseData(old,opUser,TYPE_DELETE);
            jxcDetailSnMapper.updateByPrimaryKeySelective(old);
        }
    }

    @Override
    public void saveJxcDetailSn(JxcDetailSn record, SysUser opUser) throws Exception {
    	if (HlpUtils.isEmpty(record.getId())) {
            super.autoInjectBaseData(record,opUser,TYPE_CREATE);
    		jxcDetailSnMapper.insertSelective(record);
    	} else {
            super.autoInjectBaseData(record,opUser,TYPE_UPDATE);
    		jxcDetailSnMapper.updateByPrimaryKeySelective(record);
    	}
    }

    @Override
    public List<JxcDetailSnExt> findJxcDetailSns(Map<String, Object> params, PageBean page) throws Exception {
    	return jxcDetailSnMapper.selectByPage(params, page);
    }

    @Override
    public List<JxcDetailSnExt> findJxcDetailSns(Map<String, Object> params) throws Exception {
        return jxcDetailSnMapper.selectByParams(params);
    }
}
